<?php
require_once "./ImageMergeLib.php";

$image = new ImageMergeLib();
$path = __DIR__.'/image';
$image->setPath($path);
$image->setOutName('test');
$image->setBgImage($path.'/bg.jpg');
$bg_w = $image->bg_image['w'];
$bg_h = $image->bg_image['h'];
//设置白色背景
$pure_h = round($bg_h * 0.15);
$image->addPureImage(0, $bg_h - $pure_h, $bg_h, $pure_h);
//设置头像
$head_w = $head_h = round($bg_w * 0.1);
$head_x = 20;
$head_y = ($bg_h - $pure_h) + round((($pure_h - $head_h) * 0.5)) - 20;
$image->addSrcImage($path.'/head.jpg', $head_x, $head_y, $head_w, $head_h);
//添加姓名
$image->addText('姓名', $head_x + $head_w + 10, $head_y, 15);
$image->addText('18000000001', $head_x + $head_w + 10, $head_y + 30, 13);
$image->addText('某某网络科技有限公司', $head_x, $head_y + $head_h + 10, 13);
//添加二维码
$code_w = $code_h = round($bg_w * 0.15);
$code_x = $bg_w - $code_w - 20;
$code_y = ($bg_h - $pure_h) + round((($pure_h - $code_h) * 0.5)) - 10;
$image->addSrcImage($path.'/code.jpg', $code_x, $code_y, $code_w, $code_h);
//修改二维码图标
$icon_w = $icon_h = round($code_w * 0.5);
$icon_z = round(($code_w - $icon_w) * 0.5);
$icon_x = $code_x + $icon_z;
$icon_y = $code_y + $icon_z;
$image->addSrcImage($path.'/head.jpg', $icon_x, $icon_y, $icon_w, $icon_h, true, false);
//添加二维码文字
$image->addText('长按识别小程序码', $code_x - 40, $code_y + $code_h + 5, 11);
$image->merge();